﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing";
                settings.KeyFieldName = "FTaxAuditId;FYear;FTaxClassAllowanceNo";
                settings.CallbackRouteValues = new { Controller = "AllowanceCalcManage", Action = "SelectCompanyListPartial" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(95);
                
                settings.Columns.Add("NSRBM", "纳税人编码");
                settings.Columns.Add("NSRMC", "纳税人名称");
                settings.Columns.Add("FTaxClassAllowanceName", "税种").Width=70;
                settings.Columns.Add("se", "实缴税金");
                settings.Columns.Add("FBaseAmount", "基数");
                settings.Columns.Add("FInnerRate", "基数内补贴率");
                settings.Columns.Add("FOuterRate", "基数外补贴率(补贴率)");
                settings.Columns.Add("FAllowanceAmount", "补贴金额(万元)");
                settings.Columns.Add("YBTJE", "已补金额(万元)");
                settings.Columns.Add("BTJE", "本期补贴金额(万元)");
             
                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;


                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                
                settings.CommandColumn.Visible = true;
                settings.CommandColumn.ShowSelectCheckbox = true;
                settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);

                settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
                settings.SettingsPager.FirstPageButton.Visible = true;
                settings.SettingsPager.LastPageButton.Visible = true;
                settings.SettingsPager.PageSize = EnterpriseFund.Common.GlobalConstant.CONSTRING_PAGESIZE;
                settings.SettingsPager.AlwaysShowPager = true;

                settings.Settings.ShowFooter = true;
                settings.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "NSRMC").DisplayFormat = "共"+ViewData["hus"]+"户";
 

                settings.CommandColumn.SetHeaderTemplateContent(c =>
                {
                    Html.DevExpress().CheckBox(settingsCheckBox =>
                    {
                        settingsCheckBox.Name = "cbSelectAll";
                        settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectAllRowsOnPage(); else {0}.UnselectAllRowsOnPage(); }}", settings.Name);

                        if (c.Grid.VisibleRowCount == 0)
                        {
                            settingsCheckBox.Enabled = false;

                        }
                        else
                        {
                            settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count;
                        }


                    }).Render();
                });
                                
                
                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };            
                
                
            }).Bind(Model).GetHtml()